# coding=utf-8

'''create by pbc '''

from django.conf.urls import url

from dockerManagerApp import views

urlpatterns = [
    url('^$', views.empty),
    url('^login', views.login),
    url('^home', views.homeindex),
    url('^logout', views.userLogout),
    url('^hostmanager', views.hostManager),
    url('^hostlist', views.hostList),
    url('^imagesmanager', views.imagesManager),
    url('^storemanager', views.storeManager),
    url('^host', views.hostAction),
    url('^upload', views.uploadFile),
    url('^download-(.+)', views.downloadFile),
    url('^importimages', views.importImage),
    url('^container', views.containerManager),
    url('^managercontainer', views.container_Manager),
    url('^api/nodes/uuid-(.+)', views.nodesInfo),
]

try:
    from apscheduler.scheduler import Scheduler
    from dockerManagerApp.views import updateNodeStatus

    sched = Scheduler()


    @sched.interval_schedule(seconds=3)
    def mytask():
        updateNodeStatus()


    sched.start()

except:
    from dockerManagerApp.views import updateNodeStatus
    from apscheduler.schedulers.background import BackgroundScheduler


    def mytask2():
        print('updateNodeStatus')
        updateNodeStatus()


    scheduler = BackgroundScheduler()
    scheduler.add_job(mytask2, 'interval', seconds=300)
    scheduler.start()
